package com.renjian.funplaypro.mappers;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.renjian.funplaypro.model.UserMessage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface UserMessageMapper extends BaseMapper<UserMessage> {
    @Select("select * from zw_user_msg where (from_user_id=#{userId} or to_user_id = #{userId}) and msg_type=#{type}")
    public List<UserMessage> getAllMsgs(@Param("userId") Long userId,@Param("type") Integer type);

    @Select("select * from zw_user_msg where group_id = 0 and create_time > #{createTime} and ((from_user_id=#{fromUserId} and to_user_id=#{toUserId}) or (from_user_id=#{toUserId} and to_user_id=#{fromUserId})) and is_delete=1 ORDER BY create_time asc")
    List<UserMessage> getUserMsgs(Long fromUserId, Long toUserId, Date createTime);
}
